package me.shiqiang.im.action;

import me.shiqiang.im.domain.RouterServerNode;
import me.shiqiang.im.service.RouterServerNodeServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Collection;

/**
 * Created by maliangxue on 2018/4/15.
 */
@RestController
@RequestMapping("im/server")
public class RouterServerNodeAction {


    @Autowired
    RouterServerNodeServer serverNodeService;


    @PutMapping("/registerRouterIp/{address}")
    public void registerRouterIp(@PathVariable String address) {
        RouterServerNode serverNode = new RouterServerNode();
        serverNode.setAddress(address);
        serverNodeService.save(serverNode);
    }


    @GetMapping("/getAllRouterIps")
    public Collection<String> getAllRouterIps(){
        return serverNodeService.findAll();
    }

}
